package cn.virens.web.controller.admin.masseage;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.virens.web.common.BaseUserController;

@Controller
@RequestMapping("/admin/masseage/send")
public class SendMessageContorller extends BaseUserController {
	public SendMessageContorller() {
		super("admin/masseage/send/", "message:send");
	}

	@RequestMapping(value = "index.jspx")
	public String index(HttpServletRequest request, HttpServletResponse response, Model model) {
		return returnUrl("index", model);
	}

	@ResponseBody
	@RequestMapping(value = "findUser.json")
	public Model findUser(@RequestParam(name = "term", defaultValue = "") String term, Model model) {
		List<Map<String, Object>> list = new ArrayList<>();
		for (int i = 0; i < 5; i++) {
			Map<String, Object> map = new HashMap<>();
			map.put("id", "id_" + i);
			map.put("text", "text_" + i);
			list.add(map);
		}
		model.addAttribute("results", list);
		return renderSuccess(model);
	}
}
